package com.fdd.op.sdk.autoconfigure;

import com.fdd.op.sdk.service.FddClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author panjinsheng
 */
@Configuration
@EnableConfigurationProperties(SdkProperties.class)
public class SdkAutoConfiguration {

    @Autowired
    private SdkProperties sdkProperties;

    @Bean
    public FddClientService getFddClientService(){
        Integer connectTimeout = sdkProperties.getConnectTimeout()==null?1000:sdkProperties.getConnectTimeout();
        Integer readTimeout = sdkProperties.getReadTimeout()==null?30000:sdkProperties.getReadTimeout();
        return new FddClientService(sdkProperties.getServerUrl(), sdkProperties.getAppid(), sdkProperties.getAppkey(), sdkProperties.getAuthType(), connectTimeout, readTimeout);
    }

}
